package device

import (
	"context"
	"home-butler/internal/dao"
	"home-butler/internal/model"
	"home-butler/internal/service"
)

func init() {
	service.RegisterDevice(New())
}

type sDevice struct{}

func New() service.IDevice {
	return &sDevice{}
}

func (s sDevice) FindDevice(ctx context.Context, key string) (res *model.Device, err error) {
	dao.Device.Ctx(ctx).Where(dao.Device.Columns().Key, key).Scan(&res)
	return
}
